import request from "@/config/utils/request";
import blobRequest from "@/config/utils/requestBlob";
import { getArgs, addUrlPerFix } from "@/basa/utils";
import { loadingParams } from "@/basa/utils/public";

// 字典
export function postGetEnum(params) {
  return request({
    url: `/apis/smp/basic/${params}`,
    method: "POST",
    data: { agentId: getArgs("a"), ...loadingParams }
  });
}

// 查询用户信息
export function getUserInfo(url, data) {
  return request({
    url,
    method: "POST",
    data
  });
}

export function getUserInfoA(data = {}) {
  return request({
    url:
      addUrlPerFix(process.env.VUE_APP_BASEP_URL) + "/apis/basap/getUserInfo",
    method: "post",
    data
  });
}

export function getDetail(data) {
  return request({
    url: addUrlPerFix(process.env.VUE_APP_GET_DETAIL),
    method: "post",
    data
  });
}

// 物装树
export function qryMatSubCataTree(data) {
  return request({
    url: "/apis/smp/basic/listMatSubCataTree",
    method: "post",
    data: { ...data, ...loadingParams }
  });
}

// 物装树下物资
export function qryListMateriaCata(data) {
  return request({
    url: "/apis/smp/basic/listMateriaCata",
    method: "post",
    data: { ...data, ...loadingParams }
  });
}

// 组织机构树
export function qryOmcOrgTree(data) {
  return request({
    url: "/apis/smp/basic/getOrgAgreeTree",
    method: "post",
    data
  });
}

//查询供应商
export function getSupplierData(data) {
  return request({
    url: "/apis/smp/basic/listConSupPage",
    method: "post",
    data: { ...data, ...loadingParams }
  });
}

// 搜索组织机构树
export function searchList(obj) {
  return request({
    url: "/apis/smp/basic/getOrgAgreeTreeSearch",
    method: "post",
    data: obj
  });
}

// 查询填报单位
export function getReportInOrgData(data) {
  return request({
    url: "/apis/smp/basic/listUserPartJobComInfo",
    method: "POST",
    data
  });
}

// 查询区域字典接口服务(大区)
export function getQryAreaAddress(data) {
  return request({
    url: "/apis/smp/basic/qryAreaAddress",
    method: "POST",
    data
  });
}

// 当前登陆人填报单位
export function getListUserPartJobComInfo(data) {
  return request({
    url: "/apis/smp/basic/listUserPartJobComInfo",
    method: "POST",
    data
  });
}

// 分页查询基础品牌表
export function listPageBaseBrand(data) {
  return request({
    url: "/apis/smp/smppcconc/listPageBaseBrand",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 成员分组查询
export function queryMemberGroup(data) {
  return request({
    url: "/apis/smp/basic/queryMemberGroup",
    method: "POST",
    data
  });
}

// 查询4A组织结构树（全部单位）
export function getQryTree(data) {
  return request({
    url: "/apis/smp/basic/qryOrgTree",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 公用 请求OMC组织机构下的部门及人员（不包含子集单位及其人员）
export function qryUnderOrg(data) {
  return request({
    url: "/apis/smp/org/qryUnderOrg",
    method: "post",
    data
  });
}

// 常用编码 - 分页查询(物资)
export function getListCommonCodePage(data) {
  return request({
    url: "/apis/smp/commoncode/listCommonCodePage",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 常用类别 - 分页查询(物资)
export function listCommonCategoryPage(data) {
  return request({
    url: "/apis/smp/commoncategory/listCommonCategoryPage",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 常用编码 - 分页查询(运输)
export function listTransferCommonCodePage(data) {
  return request({
    url: "/apis/smp/commoncode/listTransferCommonCodePage",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 常用类别 - 分页查询(运输)
export function listTransCommonCategoryPage(data) {
  return request({
    url: "/apis/smp/commoncategory/listTransCommonCategoryPage",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 运输物装树
export function qryMatSubCataTransTree(data) {
  return request({
    url: "/apis/smp/basic/listMatSubCataTreeTrans",
    method: "post",
    data: { ...data, ...loadingParams }
  });
}

// 运输物装树列表
export function listMateriaCataTrans(data) {
  return request({
    url: "/apis/smp/basic/listMateriaCataTrans",
    method: "post",
    data: { ...data, ...loadingParams }
  });
}

// 设备物装树
export function listMatSubCataTreeEquip(data) {
  return request({
    url: "/apis/smp/basic/listMatSubCataTreeEquip",
    method: "post",
    data: { ...data, ...loadingParams }
  });
}

// 根据合同id和业务类型查询附件
export function selectByConcIdAndSonType(data) {
  return request({
    url: "/apis/smp/smppcconc/selectByConcIdAndSonType",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 查询供应商关联关系
export function qrySupplierType(data) {
  return request({
    url: "/apis/smp/frameworkPlan/qrySupplierType",
    method: "POST",
    data
  });
}

// opre-验证合同清单引用状态
export function checkConcBillReference(data) {
  return request({
    url: "/apis/smp/ocorder/checkConcBillReference",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 查询是否有历史签名
export function qrySmpAutograph(data) {
  return request({
    url: "/apis/smp/autograph/qrySmpAutograph",
    method: "POST",
    data: { ...data, ...loadingParams }
  });
}

// 查询签名详情
export function qrySmpAutographById(data) {
  return request({
    url: "/apis/smp/autograph/qrySmpAutographById",
    method: "POST",
    data
  });
}

// 更新二维码状态
export function qrySmpAutographCode(data) {
  return request({
    url: "/apis/smp/autograph/qrySmpAutographCode",
    method: "POST",
    data
  });
}

// 基本信息 - 项目名称
export function qryProjectDataAll(data) {
  return request({
    url: "/apis/smp/basic/qryProjectDataAll",
    method: "POST",
    data
  });
}

// 基本信息 - 核算组织
export function listAccountingUnitByBO(data) {
  return request({
    url: "/apis/smp/basic/listAccountingUnitByBO",
    method: "POST",
    data
  });
}

// 导出(详情)
export function detailExport(data) {
  return blobRequest({
    url: `/apis/smp/${data.type}`,
    method: "POST",
    responseType: "blob",
    data: { ...data, ...loadingParams, loadingMessage: "导出中,请稍等..." }
  });
}

// 签字pdf下载
export function smpPdfExport(data) {
  return request({
    url: `/apis/smp/exportPdf/smpPdfExport`,
    method: "POST",
    data: { ...data, ...loadingParams, loadingMessage: "导出中,请稍等..." }
  });
}

// 附件下载
export function downloadAttachment(data) {
  return blobRequest({
    url: `/apis/smp/oss/users/signup/download`,
    method: "post",
    responseType: "blob",
    data: { ...data, ...loadingParams, loadingMessage: "导出中,请稍等..." }
  });
}
